export default ({ request, serviceForMock, mock, faker }) => {

  // Mock数据配置
  mock.onGet('/report/device/list').reply(200, {
    code: 0,
    msg: 'success',
    data: {
      page: {
        totalCount: 50,
        pageSize: 10,
        totalPage: 5,
        currPage: 1,
        list: Array.from({ length: 10 }, (_, index) => ({
          id: index + 1,
          deviceType: ['电表', '水表'][index % 2],
          deviceId: `${index % 2 === 0 ? 'E' : 'W'}${String(index + 1).padStart(4, '0')}`,
          roomNumber: `10${index + 1}`,
          tenantName: faker.name.findName(),
          startReading: faker.random.number({ min: 100, max: 500 }),
          endReading: faker.random.number({ min: 500, max: 1000 }),
          usage: faker.random.number({ min: 50, max: 200 }),
          unitPrice: faker.random.number({ min: 0.5, max: 5 }),
          totalAmount: faker.random.number({ min: 25, max: 1000 }),
          reportDate: faker.date.recent().toISOString().split('T')[0]
        }))
      }
    }
  })

  // 首页统计数据
  mock.onGet('/dashboard/statistics').reply(200, {
    code: 0,
    msg: 'success',
    data: {
      // 快捷功能卡片数据
      quickActions: [
        { title: '充值缴费', count: 0, icon: 'credit-card' },
        { title: '一键开户', count: 0, icon: 'user-plus' },
        { title: '账单查询', count: 0, icon: 'file-text' },
        { title: '电表管理', count: 0, icon: 'zap' },
        { title: '水表管理', count: 0, icon: 'droplet' },
        { title: '保电管理', count: 0, icon: 'shield' }
      ],
      // 近30天费用占比
      costRatio: {
        total: 16112.90,
        items: [
          { name: '聚合', value: 0.00, percentage: 0.00 },
          { name: '微信', value: 0.00, percentage: 0.00 },
          { name: '支付宝', value: 0.00, percentage: 0.00 },
          { name: '现金', value: 0.00, percentage: 100.00 },
          { name: '银联', value: 0.00, percentage: 0.00 }
        ]
      },
      // 缴费类型
      paymentType: {
        total: 16112.90,
        items: [
          { name: '预存', value: 19327.00, color: '#ff6b35' },
          { name: '退费', value: 19327.00, color: '#4285f4' }
        ]
      },
      // 设备状态统计
      deviceStatus: {
        gateway: { online: 112, offline: 4 },
        fourG: { online: 112, offline: 4 },
        electric: { online: 112, offline: 4 },
        water: { online: 112, offline: 4 }
      }
    }
  })

  return {
    // 设备报表
    report_device_list(params = {}) {
      return request({
        url: '/report/device/list',
        params
      })
    },

    report_device_export(params = {}) {
      return request({
        url: '/report/device/export',
        params,
        responseType: 'blob'
      })
    },

    // 首页统计数据
    dashboard_statistics(params = {}) {
      return request({
        url: '/dashboard/statistics',
        params
      })
    }
  }
}

